﻿using System.ComponentModel.Composition;
using System.Web;

namespace SS.AspNet.Utilities
{
    /// <summary>
    /// The class is used to store a value in Session
    /// </summary>
    [Export(typeof(SessionStoreHelper))]
    [PartCreationPolicy(CreationPolicy.Shared)]
    public class SessionStoreHelper
    {
        public void Delete(string key)
        {
            HttpContext.Current.Session.Remove(key);
        }

        public bool IsExist(string key)
        {
            return HttpContext.Current.Session[key] != null;
        }

        public T Get<T>(string key)
        {
            return (T)HttpContext.Current.Session[key];
        }

        public void Store<T>(string key, T value)
        {
            HttpContext.Current.Session[key] = value;
        }
    }
}